<%@ Page Language="VB" StylesheetTheme="default" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="InstrumentLogic.aspx.vb" Inherits="Modules_InstrumentLogic" title="Instrument Logic Page" %>
<%@ Register Assembly="DotNetPM.Web.UI.WebControls" TagPrefix="cc" Namespace="DotNetPM.Web.UI.WebControls" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <div>
        <table id="Table1" border="0" cellpadding="2" cellspacing="2" width="100%">
            <tr>
                <td colspan="4">
                    <strong><font size="2">ADD QUESTION LOGIC :
                        <asp:Label ID="lblLevel" runat="server" Text="Level"></asp:Label></font></strong></td>
                <td align="right" colspan="1">
                    <asp:LinkButton ID="lbBack" runat="server" CausesValidation="False" ForeColor="Blue">Back</asp:LinkButton></td>
            </tr>
            <tr style="color: #000000">
                <td colspan="5">
                    <hr size="1" width="100%" />
                    &nbsp;</td>
            </tr>
            <tr>
                <td rowspan="7" valign="top" width="15">&nbsp;</td>
                <td valign="top" align=right >
                    <strong>Question :</strong></td>
                <td valign="top" style="border-right: black 1px solid; padding-right: 10px; border-top: black 1px solid; padding-left: 10px; padding-bottom: 10px; border-left: black 1px solid; padding-top: 10px; border-bottom: black 1px solid">
                    <strong> </strong>
                        <asp:Label ID="lblQuestion" runat="server" Font-Bold="True" ForeColor="MediumBlue"></asp:Label></td>
                <td colspan="2" valign="top">
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td  >
                    <asp:XmlDataSource ID="ControlXDS" runat="server" DataFile="~/Secure/Controls/ControlList.xml" />
                    <asp:ObjectDataSource ID="LogicsODS" runat="server" OldValuesParameterFormatString="original_{0}"
                        SelectMethod="GetInstrumentLogics" TypeName="DotNetPM.Business.Questionnaire.InstrumentODS">
                        <SelectParameters>
                            <asp:SessionParameter Name="ParentUID" SessionField="questionnaire_currentGuid" Type="String" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                </td>
                <td colspan="2" >
                    </td>
            </tr>
            <tr>
                <td align="right" valign="top">
                </td>
                <td align="right" valign="top">
                    <asp:LinkButton ID="lbutNew" runat="server" Font-Bold="True"><SPAN style="POSITION: relative; TOP: -4px; left:-4px">Add A New Question</SPAN><img src="../../Images/New.gif" style="border-width:0px;POSITION: relative;" /></asp:LinkButton></td>
                <td align="left" colspan="2" rowspan="1" width="300">
                </td>
            </tr>
            <tr>
                <td valign="top" align=right>
                    <strong>Logics :</strong></td>
                <td valign="top" align="center">
                    <asp:GridView ID="gvLogics" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="LogicsODS" Width="800px" EmptyDataText="There is no logic definded for this question yet.">
                        <Columns>
                            <asp:TemplateField HeaderText="Logic" SortExpression="Logic">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# TranslateLogic(Eval("Logic")) %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Left" />
                                <HeaderStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Next Question to Ask" SortExpression="QuestionID">
                                <ItemTemplate>
                                    <asp:HiddenField ID="hfUID" runat=server Value='<%# Bind("UID") %>' />
                                    <asp:HiddenField ID="hfParentUID" runat=server Value='<%# Bind("ParentUID") %>' />
                                    <asp:HiddenField ID="hfLogic" runat=server Value='<%# Bind("Logic") %>' />
                                    <asp:HiddenField ID="hfEnable" runat=server Value='<%# Bind("Enabled") %>' />
                                    <asp:HiddenField ID="hfQuestionID" runat=server Value='<%# Bind("QuestionID") %>' />
                                    <asp:Label ID="Label2" runat="server" Text='<%# GetQuestion(Eval("QuestionID")) %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Left" />
                                <HeaderStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>                                    
                                    <cc:DynImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="SelectLogic"
                                        CommandArgument='<%# Container.DataItemIndex %>' ImageUrl="~/Images/Edit_0.gif" Text="Select" ToolTip="Edit Logic" />
                                    <cc:DynImageButton ID="ImageButton2" runat="server" CausesValidation="False" CommandName="EditLogic" 
                                        CommandArgument='<%# Container.DataItemIndex %>' ImageUrl="~/Images/Logic_0.gif" Text="Edit Logic" ToolTip="Define Sub-logic" />
                                </ItemTemplate>
                                <ItemStyle Width="40px" HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView></td>
                <td align="left" colspan="2" rowspan="1" width="300">
                    <asp:ImageButton ID="ibutTop" runat="server" ImageUrl="~/Images/Tp.gif"
                        Visible="False" />
                    <asp:ImageButton ID="ibutUp" runat="server" ImageUrl="~/Images/Up.gif"
                        Visible="False" />
                    <asp:ImageButton ID="ibutDown" runat="server" ImageUrl="~/Images/Dn.gif"
                        Visible="False" />
                    <asp:ImageButton ID="ibutButtom" runat="server" ImageUrl="~/Images/Bm.gif"
                        Visible="False" /></td>
            </tr>
            <tr>
                <td align="right" valign="top">
                </td>
                <td align="right" valign="top">
                    <asp:ImageButton ID="ibutBack" runat="server" ImageUrl="~/Images/Back.gif" /></td>
                <td colspan="2" valign="top">
                </td>
            </tr>
            <tr runat=server id="trEdit" visible=false >
                <td valign="top" runat=server id="tdAddEdit" align=right>
                </td>
                <td valign="top">
<a name="editarea" />
<table cellspacing="2" cellpadding="2" border="0" style="background-color:White;border-color:Black;border-width:1px;border-style:Solid;width:800px;">
                        <tr  style="color:MistyRose;background-color:#4A3C8C;font-weight:bold;" align="center">
                            <td>
                                Answer Type
                            </td>
                            <td>
                                Operator
                            </td>
                            <td colspan="2" width="600">
                                Value to Compare
                            </td>
                        </tr>
                        <asp:PlaceHolder ID="phLoader" runat="server"></asp:PlaceHolder>
                        <tr  style="color:MistyRose;background-color:#4A3C8C;font-weight:bold;" align="center">
                            <td colspan=4>Sequencial Question to Ask</td>
                        </tr>
                        <tr style="color:Black;background-color:#EEEEEE;">
                            <td colspan="4" valign="top">
                                <table border=0 >
                                    <tr>
                                        <td width=100 align="right"> Filter by Category : </td>
                                        <td width=120 >
                                            <asp:DropDownList ID="ddlCategories" runat="server" AppendDataBoundItems="True" DataSourceID="CategoryODS" DataTextField="Name" DataValueField="ID">
                                                <asp:ListItem Selected="True" Value="0">None</asp:ListItem>
                                            </asp:DropDownList>&nbsp;
                                        </td>
                                        <td width=120>
                                            <asp:ObjectDataSource ID="CategoryODS" runat="server" OldValuesParameterFormatString="original_{0}"
                                                SelectMethod="GetCategories" TypeName="DotNetPM.Business.Questionnaire.CategoryODS">
                                            </asp:ObjectDataSource>
                                        </td>
                                        <td rowspan="3" width="120">
                                        </td>
                                        <td rowspan="3">
                                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Adding" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">Question contains : </td>
                                        <td ><asp:TextBox ID="txtStringToSearch" runat="server"></asp:TextBox></td>
                                        <td>
                                            <asp:Button ID="butSearch" runat="server" Text="Search" Width="60px" />&nbsp;
                                            <asp:Button ID="butClear" runat="server" Text="Clear" Width="60px" /></td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                        </td>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr style="color:Black;background-color:Gainsboro;">
                            <td valign="top" align="center" colspan=4>
                                <table border=0 cellpadding=0 cellspacing=0>
                                    <tr>
                                        <td align="right">
                                            <asp:LinkButton ID="lbutCreate" runat="server" Font-Bold="True"><SPAN style="POSITION: relative; TOP: -4px; left:-4px">Create A New Question</SPAN><img src="../../Images/New.gif" style="border-width:0px;POSITION: relative;" /></asp:LinkButton>
                                <asp:ListBox ID="lstQuestions" runat="server" DataSourceID="odsQuestions" DataTextField="Question"
                                    DataValueField="ID" Width="780px" ValidationGroup="Adding">
                                </asp:ListBox>
                                <asp:ObjectDataSource ID="odsQuestions" runat="server"
                                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetQuestions" TypeName="DotNetPM.Business.Questionnaire.QuestionODS">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="ddlCategories" Name="CategoryID" PropertyName="SelectedValue"
                                            Type="Int32" />
                                        <asp:ControlParameter ControlID="txtStringToSearch" Name="StringToSearch" PropertyName="Text"
                                            Type="String" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="lstQuestions"
                                                Display="Dynamic" ErrorMessage="&nbsp;* Please select a question first !" ValidationGroup="Preview"></asp:RequiredFieldValidator>
                                        </td>
                                        <td>
                                <asp:RequiredFieldValidator ID="reqVal" runat="server" ErrorMessage="Please select a question for this logic !" ControlToValidate="lstQuestions" ValidationGroup="Adding" Width="0px">*</asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                </table>
                                </td>
                        </tr>
                        <tr style="color:Black;background-color:#EEEEEE;">
                            <td align="right" colspan="4">
                                <asp:Button ID="butUpdate" runat="server" Text="Update Logic" ValidationGroup="Adding" /><asp:Button ID="butAdd" runat="server" Text="Add Logic" ValidationGroup="Adding" />&nbsp;
                                &nbsp;<asp:Button ID="butPreview" runat="server" Text="Preview"
                                                ValidationGroup="Preview" />&nbsp;
                                            <asp:Button ID="butCancel" runat="server" Text="Cancel" CausesValidation="False" ValidationGroup="Adding" /></td>
                        </tr>
                    </table>
                </td>
                <td colspan="2" valign="top">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="right" valign="top">
                </td>
                <td align="right" valign="top">
                    </td>
                <td colspan="2" valign="top">
                    </td>
            </tr>
            <tr>
                <td rowspan="1" valign="top" width="15">
                </td>
                <td align="right" valign="top">
                </td>
                <td valign="top">
                </td>
                <td colspan="2" valign="top">
                </td>
            </tr>
        </table>
    
    </div>
</asp:Content>

